package com.hb.core.pojo.project.evaluation.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hb.core.pojo.project.evaluation.entity.EvaluationSecond;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 专家二级评审表 Mapper 接口
 * </p>
 *
 * @author jinhaolin
 * @since 2022-04-13
 */
public interface EvaluationSecondMapper extends BaseMapper<EvaluationSecond> {

    /**
     * 根据标段id和专家id获取二级评审项结果
     *
     * @param sectionId
     * @param expertId
     * @return
     */
    List<EvaluationSecond> findBySectionIdAndExpertIdAndSecondId(@Param("sectionId") Long sectionId,
                                                                 @Param("expertId") Long expertId,
                                                                 @Param("secondReviewItemId") Long secondReviewItemId);

    /**
     * 根据标段id 和 二级评审项id 获取二级评审项结果
     *
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    List<EvaluationSecond> findBySectionIdAndSecondId(@Param("sectionId") Long sectionId,
                                                      @Param("secondReviewItemId") Long secondReviewItemId);

    List<EvaluationSecond> findBySectionIdAndSecondIdAndOrgId(@Param("sectionId") Long sectionId,
                                                              @Param("secondReviewItemId") Long secondReviewItemId,
                                                              @Param("orgId") Long orgId);

    /**
     * 根据标段id、二级评审项id、专家id 获取未淘汰的企业的二级评审项结果
     *
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    List<EvaluationSecond> findBySectionIdAndSecondIdAndExpertIdNoEliminate(@Param("sectionId") Long sectionId,
                                                                            @Param("secondReviewItemId") Long secondReviewItemId,
                                                                            @Param("expertId") Long expertId);

    /**
     * 根据标段id、二级评审项id获取未淘汰的企业id列表
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    List<Long> findOrgListBySectionIdAndSecondIdNoEliminate(@Param("sectionId") Long sectionId,
                                                            @Param("secondReviewItemId") Long secondReviewItemId);

    /**
     * 根据标段id、二级评审项id 查询未评审状态的数量
     *
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    Integer findNoSubmitCountBySectionIdAndSecondId(@Param("sectionId") Long sectionId,
                                                    @Param("secondReviewItemId") Long secondReviewItemId);

    /**
     * 确认汇总
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    Integer editEvaluationStatus(@Param("sectionId") Long sectionId,
                                 @Param("secondReviewItemId") Long secondReviewItemId,
                                 @Param("evaluationStatus") Integer evaluationStatus);


    /**
     * @param sectionId:标段id
     * @param secondReviewItemId:
     * @Description:查询未被淘汰的公司名称和公司
     * @Author: zhongdl
     * @Date:2022/4/20 10:49
     * @return: {@link List< Long> }
     **/
    List<EvaluationSecond> listNotEliminate(@Param("sectionId") Long sectionId,
                                @Param("secondReviewItemId") Long secondReviewItemId);

    /**
     * 修改专家对应三级评审点的得分和状态
     * @author tian
     * @date 2022-4-20 15:52
     * @param evaluationSecond
     * @return java.lang.Integer
     */
    Integer updateFinalScoreByExpertIdAndSecondReviewItemId(EvaluationSecond evaluationSecond);

    /**
     * 更新定量评审状态
     * @param evaluationSecond
     * @return
     */
    Integer updateApproveFlagByExpertIdAndSecondReviewItemId(EvaluationSecond evaluationSecond);


    /**
     * 查询专家是否对报价评审确认
     * @author tian
     * @date 2022-4-20 17:19
     * @param expertId
     * @param sectionId
     * @param secondReviewItemId
     * @return java.lang.Integer
     */
    Integer countByEvaluationStatus(@Param("expertId") Long expertId,
                                    @Param("sectionId") Long sectionId,
                                    @Param("secondReviewItemId") Long secondReviewItemId);



    /**
     * 查询当前企业是否合格
     * @author tian
     * @date 2022-4-21 16:14
     * @param orgId
     * @param sectionId
     * @param secondReviewItemId
     * @return java.lang.Integer
     */
    Integer countByApproveFlag(@Param("orgId") Long orgId,
                                 @Param("sectionId") Long sectionId,
                                 @Param("secondReviewItemId") Long secondReviewItemId);

    /**
     * 查询当前企业是否淘汰
     * @author tian
     * @date 2022-4-21 16:14
     * @param orgId
     * @param sectionId
     * @param secondReviewItemId
     * @return java.lang.Integer
     */
    Integer countByEliminateFlag(@Param("orgId") Long orgId,
                                 @Param("sectionId") Long sectionId,
                                 @Param("secondReviewItemId") Long secondReviewItemId);
    /**
     *
     * @Description:根据标段id和评审项类型获得所有的二级评审项
     * @Author: zhongdl
     * @Date:2022/4/21 9:15
     * @param sectionId:
     * @param firstReviewItemType:
     * @return: {@link List< EvaluationSecond> }
     **/
    List<EvaluationSecond> listEvaluationSecond(@Param("sectionId") Long sectionId, @Param("firstReviewItemType") Integer firstReviewItemType);

    /**
     * 统计未完成汇总的数量
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    Integer noSummaryCount(@Param("sectionId") Long sectionId,
                           @Param("secondReviewItemId") Long secondReviewItemId);

    /**
     * 更新企业的淘汰状态
     * @param sectionId
     * @param secondReviewItemId
     * @param idList
     * @return
     */
    Integer updateOrgEliminateStatus(@Param("sectionId") Long sectionId, @Param("secondReviewItemId") Long secondReviewItemId, @Param("idList") List<Long> idList);

    /**
     * 取消企业淘汰状态
     * @param sectionId
     * @param secondReviewItemId
     * @return
     */
    Integer cancelOrgEliminateStatus(@Param("sectionId") Long sectionId, @Param("secondReviewItemId") Long secondReviewItemId);
}
